import basicApi from '@/api/basic'
const basic = {
    namespaced: true,
    state: {
        deptTrees: [],
        roles: [],
        roleByTypes: [],
        menus: [],
        perms: [],
        pDics: [],
    },
    getters: {

    },
    mutations: {
    },
    actions: {
        doDeptTreeOfBasic({commit,state}) {
            return basicApi.doDept().then(result=>{
                state.deptTrees = result.bean;
            });
        },
        doRolesOfBasic({ commit, state }) {
            return basicApi.doRole().then(result=>{
                state.roles = result.bean;
            });
        },
        doRoleByTypeOfBasic({ commit, state }, type) {
            return basicApi.doRoleByType({type: type}).then(result=>{
                state.roleByTypes = result.bean;
            });
        },
        doMenusOfBasic({ commit, state }) {
            return basicApi.doMenu().then(result=>{
                state.menus = result.bean;
            });
        },
        doPermsOfBasic({ commit, state },menuId) {
            return basicApi.doPermsByMenuId({menuId: menuId}).then(result=>{
                state.perms = result.bean;
            });
        },
        doPDicOfBasic({ commit, state}) {
            return basicApi.doPdic().then(result => {
               state.pDics = result.bean;
            });
        },
    }
}

export default basic;
